package com;

import java.util.*;

public class PokeDemo {
    public static void main(String[] args) {
        //54随机发到4个玩家
        Map<Integer,String> pokes = new HashMap<>();

        //根据花色和牌号得到52张牌
        String[] types = {"♥","♠","♦","♣"};
        String[] numbers = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        //牌号
        List<Integer> pokeNumbers = new ArrayList<>();
        int index = 0;
        for(String number: numbers){
            for(String type: types){
                String poke = type+number;
                pokes.put(index,poke);
                pokeNumbers.add(index);
                index++;
            }
        }
        pokes.put(52,"小🃏");
        pokes.put(53,"大🃏");
        pokeNumbers.add(52);
        pokeNumbers.add(53);

        //将0-53全部随机打乱（直接用方法）
        System.out.println(pokeNumbers);
        Collections.shuffle(pokeNumbers);
        System.out.println(pokeNumbers);
        //创建4个人的装牌号的集合

        List<Integer> pokeNumber1 = new ArrayList<>();
        List<Integer> pokeNumber2 = new ArrayList<>();
        List<Integer> pokeNumber3 = new ArrayList<>();
        List<Integer> pokeNumber4 = new ArrayList<>();

        for(int i=0;i<pokeNumbers.size();i++){
            if(i<17){
                pokeNumber1.add(pokeNumbers.get(i));
            }else if(i<34){
                pokeNumber2.add(pokeNumbers.get(i));
            }else if(i<51){
                pokeNumber3.add(pokeNumbers.get(i));
            }else {
                pokeNumber4.add(pokeNumbers.get(i));
            }
        }
        //牌号分完之后，排序
        Collections.sort(pokeNumber1);
        Collections.sort(pokeNumber2);
        Collections.sort(pokeNumber3);
        Collections.sort(pokeNumber4);
        List<String> poke1 = new ArrayList<>();
        List<String> poke2 = new ArrayList<>();
        List<String> poke3 = new ArrayList<>();
        List<String> poke4 = new ArrayList<>();

        for(Integer i: pokeNumber1){
            poke1.add(pokes.get(i));
        }
        for(Integer i: pokeNumber2){
            poke2.add(pokes.get(i));
        }
        for(Integer i: pokeNumber3){
            poke3.add(pokes.get(i));
        }
        for(Integer i: pokeNumber4){
            poke4.add(pokes.get(i));
        }
        System.out.println(poke1);
        System.out.println(poke2);
        System.out.println(poke3);
        System.out.println(poke4);
    }
}
